﻿ using System;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using System.Linq;
using LogAnalyzer.ViewModel;
using LogAnalyzer.View;
using LogAnalyzer.Model;

namespace LogAnalyzer
{
    public partial class MainWindowTest : Window
    {
        private MainViewModel ViewModel;

        public MainWindowTest()
        {
            InitializeComponent();
            ViewModel = new MainViewModel();
            ViewModel.routeGridViewModel.RowClick += RowClick;
            g.DataContext = ViewModel.routeGridViewModel;
            this.DataContext = ViewModel;
        }

        void RowClick(object sender, EventArgs e)
        {
            var row = sender as RoutingData;
            if (row != null)
            {
                var view = new GraphView();
                var viewModel = new GraphViewModel(row) { Header = "Routing Graph" };
                viewModel.loadJoinGraph += viewModel_loadJoinGraph;
                view.DataContext = viewModel;
                this.tabControl.Items.Add(view);
            }
        }

        void viewModel_loadJoinGraph(object sender, EventArgs e)
        {
            var node = sender as Node;
            if (node != null)
            {
                var view = new GraphView();
                var viewModel = new JoinGraphViewModel(node) { Header = "Join Graph" };
                //viewModel.AddNodeJoin(node);
                view.DataContext = viewModel;
                this.tabControl.Items.Add(view);
            }
        }
    }
}
